﻿using System;
using System.Collections.Generic;
using System.Text;
using Webapiv3.Domain.Entity;
using Webapiv3.Domain.Enum;
using Webapiv3.inetrface;

namespace Webapiv3.Utils.Log
{
    public static class LogHelper
    {
        public static void Logger(this ILog log, Exception exception, LogsLevel logsLevel, int userId = 0)
        {
            var item = new Logs
            {
                LogLevel = (int)logsLevel,
                ShortMessage = exception.Message,
                FullMessage = exception.ToString(),
                UserId = userId
            };
            log.Insert(item);
        }
        public static void Info(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.信息, int userId = 0)
        {
            Logger(log, exception, logsLevel, userId);
        }
        public static void Debug(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.调试, int userId = 0)
        {
            Logger(log, exception, logsLevel, userId);
        }
        public static void Error(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.错误, int userId = 0)
        {
            Logger(log, exception, logsLevel, userId);
        }
        public static void Fatal(this ILog log, Exception exception, LogsLevel logsLevel = LogsLevel.崩溃, int userId = 0)
        {
            Logger(log, exception, logsLevel, userId);
        }
    }
}
